/*
 * Copyright (c) 2025 Industrial Software Feature Database
 */
package com.comac.ins.isfd.constant.enums;

import com.comac.ins.common.core.utils.StringUtils;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 文件后缀
 *
 * @author hxloongs
 * @date 2025-01-13
 */
@AllArgsConstructor
@Getter
public enum IsfdModelMeshFileSuffixEnum {
    BDF("bdf", "bdf文件"),
    OUT("out", "out文件"),
    DAT("dat", "dat文件");
    private final String value;
    private final String desc;

    public static String getDescByValue(String value) {
        IsfdModelMeshFileSuffixEnum isfdModelMeshFileSuffixEnum = forValue(value);
        if (isfdModelMeshFileSuffixEnum == null) {
            return null;
        }
        return isfdModelMeshFileSuffixEnum.getDesc();
    }

    public static IsfdModelMeshFileSuffixEnum forValue(String value) {
        if (StringUtils.isBlank(value)) {
            return null;
        }
        for (IsfdModelMeshFileSuffixEnum isfdModelMeshFileSuffixEnum : IsfdModelMeshFileSuffixEnum.values()) {
            if (isfdModelMeshFileSuffixEnum.getValue().equalsIgnoreCase(value)) {
                return isfdModelMeshFileSuffixEnum;
            }
        }
        return null;
    }

    public static IsfdModelMeshFileSuffixEnum forDesc(String desc) {
        if (desc == null) {
            return null;
        }
        for (IsfdModelMeshFileSuffixEnum isfdModelMeshFileSuffixEnum : IsfdModelMeshFileSuffixEnum.values()) {
            if (desc.equals(isfdModelMeshFileSuffixEnum.getDesc())) {
                return isfdModelMeshFileSuffixEnum;
            }
        }
        return null;
    }


    /**
     * 判断是否是bdf
     */
    public static Boolean isBdf(String value) {
        if (StringUtils.isBlank(value)) {
            return Boolean.FALSE;
        }

        if (BDF.value.equalsIgnoreCase(value)) {
            return Boolean.TRUE;
        }
        return Boolean.FALSE;
    }
}
